﻿using MediatR;
using S.EarTag.API.Mediator.MediatorCommand.MarkCommand;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;

namespace S.EarTag.API.Mediator.MediatorCommandHandler.MarkCommandHandler
{
    public class MarkCreateCommandHandler : IRequestHandler<MarkCreateCommand, bool>
    {
        private readonly IMarkModelRepository _markModelRepository;
        public MarkCreateCommandHandler(IMarkModelRepository markModelRepository)
        {
            _markModelRepository = markModelRepository;
        }
        /// <summary>
        /// 添加戴标数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<bool> Handle(MarkCreateCommand request, CancellationToken cancellationToken)
        {
            return await _markModelRepository.AddAsync(new MarkModel
            {
                EarTag = request.EarTag,
                EITag = request.EITag,
                NewEITag= request.NewEITag,
                WearId = request.WearId,
                MarkState = request.MarkState,
                CreateBy = request.CreateBy,
                CreateDate = request.CreateDate,
                UpdateBy = request.UpdateBy,
                UpdateDate = request.UpdateDate,
                UseState= request.UseState,
            });
        }
    }
}
